using UnityEngine;

public class Player : Creature
{
	[Header("Requirement")]
	public AudioSource audioSource;

	public CameraController cameraController;

	public CreatureController creatureController;

	private UI ui;

	public void Begin()
	{
		ui = Library.ui;
		CreatureLoader.Fill(this, true);
	}

	public new void Move(Vector2 direction)
	{
		base.Move(direction);
		cameraController.SetPosition(model.position);
		creatureController.SetPosition(model.position);
		if ((movementAbility == null || !movementAbility.IsControllingLegs()) && !swimming)
		{
			if (currentDirection.magnitude == 0f)
			{
				StopLegsAnimation();
			}
			else
			{
				StartLegsAnimation();
			}
		}
	}

	public override void PlaySound()
	{
		audioSource.Play();
	}

	public override void Eat(Food food, float size)
	{
		base.Eat(food, size);
		Library.controller.SetDNA(0.025f * size);
		ui.UpdateDnaBar();
	}

	public override void Death()
	{
		Library.controller.Defeat();
	}

	public override void SetHealth(float value)
	{
		base.SetHealth(value);
		ui.UpdateHealthBar();
	}

	public override void SetStamina(float value)
	{
		base.SetStamina(value);
		ui.UpdateStaminaBar();
	}
}
